package com.chinasoft.movies.service.impl;

import com.chinasoft.movies.mapper.Top50MoviesMapper;
import com.chinasoft.movies.pojo.PageResult;
import com.chinasoft.movies.pojo.Top50Movies;
import com.chinasoft.movies.service.Top50MoviesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Top50MoviesServiceImpl implements Top50MoviesService {
    @Autowired
    private Top50MoviesMapper top50MoviesMapper;

    @Override
    public PageResult<Top50Movies> queryTop50MoviesByPage(int page, int size) {
        int offset = (page - 1) * size;
        List<Top50Movies> data = top50MoviesMapper.queryTop50MoviesByPage(offset, size);
        int total = top50MoviesMapper.countTop50Movies();

        return new PageResult<>(total, page, size, data);
    }

}
